﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class EnemyChoice : MonoBehaviour {

	public GameObject [] enemySprite;
	public Transform timerGaugeTrans;
	Vector3 originScale;
	List<int> sidList = new List<int>();

	void Awake()
	{
		originScale = timerGaugeTrans.localScale;
	}

	public void HideAll()
	{
		timerGaugeTrans.localScale = originScale;
		enemySprite[0].SetActive(false);
		enemySprite[1].SetActive(false);
		enemySprite[2].SetActive(false);
	}

	public void StartTimer()
	{
		timerGaugeTrans.localScale = originScale;
		LeanTween.scaleX( timerGaugeTrans.gameObject, 0, 10);
		StartCoroutine("CoTimeOver");
	}

	public void StopTimer()
	{
		StopCoroutine("CoTimeOver");
	}

	IEnumerator CoTimeOver()
	{
		yield return new WaitForSeconds(10);
		sidList.Clear();
		foreach(GameObject go in enemySprite)
		{
			if(go.activeSelf)
			{
				sidList.Add (go.GetComponent<EnemyChoiceEnemy>().sid);
			}
		}
		int nIndex = Random.Range(0, sidList.Count);
		if( sidList[nIndex] !=0)
			SkillManager.Instance.CastSkillToTarget( sidList[nIndex] );
	}
}
